<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>新增党建动态</title>
<link href="/djzx/css/style.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="/djzx/js/jquery-1.8.1.min.js"></script>
<script language="javascript" type="text/javascript" src="/djzx/js/My97DatePicker/WdatePicker.js"></script>
<script language="JavaScript" type="text/javascript" src="/djzx/js/backPage/clientSideApp.js"></script>
<script charset="utf-8" src="/djzx/js/kindeditor-4.1.10/kindeditor.js"></script>
<script charset="utf-8" src="/djzx/js/kindeditor-4.1.10/lang/zh_CN.js"></script>
<script type="text/javascript" charset="utf-8" src="/djzx/js/myJs2.js"></script>
<script language="javascript">

window.onload = function(){
	var flag = $('#flag').val();
	if(flag != ""){
		alert(flag);
	}
	$('#flag').val('');
}

function goback(){
	window.location.href="/djzx/CommunityPartyActivityAction!getPartyActivityListForPage.action";
}

/* function savePartyActivity(){
	var partyName = $.trim($('#partyName').val());
	var activityName = $.trim($('#activityName').val());
	var activityType = $.trim($('#activityType').val());
	var activityDate = $.trim($('#activityDate').val());
	var address = $.trim($('#address').val());
	var attendNum = $.trim($('#attendNum').val());
	editor6.sync();
	var content = $.trim($('#content').val());
	editor7.sync();
	var situation = $.trim($('#situation').val());
	
	if(partyName==""){
		alert("党组织名称不能为空");
		return;
	}
	if(activityName==""){
		alert("活动名称不能为空");
		return;
	}
	if(activityDate==""){
		alert("活动日期不能为空");
		return;
	}
	if(address==""){
		alert("活动地址不能为空");
		return;
	}
	if(attendNum==""){
		alert("参加人数不能为空");
		return;
	}else if(isNaN(attendNum)){
		alert("参加人数必须为数字");
		return;
	}
	if(content==""){
		alert("活动内容不能为空");
		return;
	}
	if(situation==""){
		alert("活动情况不能为空");
		return;
	}
	var images = $("#image");
	for(var i=0;i<images.length;i++){
		var image = images[i];
		if($(image).val().length==0){
			alert("上传图片不能为空");
			return;
		}
	}
	
	attendNum = parseInt(attendNum);
	var fd = new FormData();
	fd.append('partyActivity.partyName',partyName);
	fd.append('partyActivity.activityName',activityName);
	fd.append('partyActivity.activityType',activityType);
	fd.append('partyActivity.activityDate',activityDate);
	fd.append('partyActivity.address',address);
	fd.append('partyActivity.attendNum',attendNum);
	fd.append('partyActivity.content',content);
	fd.append('partyActivity.situation',situation);
	fd.append('imageFile',images[0]);
	
	$.ajax({
	    url:"${pageContext.request.contextPath}/CommunityPartyActivityAction!savePartyActivity.action",
	    type:"POST",
	    data:fd,
	    dataType: "json", 
	    contentType: false, //必须
	    processData: false, //必须
	    success:function(data){
	    	alert(data.message);
			if(data.success){
				location.href="/djzx/CommunityPartyActivityAction!getPartyActivityListForPage.action";
			}
	    }
	}); 
}  */

function savePartyActivity(){
	var partyName = $.trim($('#partyName').val());
	var activityName = $.trim($('#activityName').val());
	var activityType = $.trim($('#activityType').val());
	var activityDate = $.trim($('#activityDate').val());
	var address = $.trim($('#address').val());
	var attendNum = $.trim($('#attendNum').val());
	editor6.sync();
	var content = $.trim($('#content').val());
	editor7.sync();
	var situation = $.trim($('#situation').val());
	
	if(partyName==""){
		alert("党组织名称不能为空");
		return;
	}
	if(activityName==""){
		alert("活动名称不能为空");
		return;
	}
	if(activityDate==""){
		alert("活动日期不能为空");
		return;
	}
	if(address==""){
		alert("活动地址不能为空");
		return;
	}
	if(attendNum==""){
		alert("参加人数不能为空");
		return;
	}else if(isNaN(attendNum)){
		alert("参加人数必须为数字");
		return;
	}
	if(content==""){
		alert("活动内容不能为空");
		return;
	}
	if(situation==""){
		alert("活动情况不能为空");
		return;
	}
	var images = $(":file");
	for(var i=0;i<images.length;i++){
		var image = images[i];
		if($(image).val().length==0){
			alert("上传图片不能为空");
			return;
		}
	}
	
	$('#form1').submit();
} 

$(document).ready(function(){
	// 获取partyNameParam参数
	var partyNameParam = $('#partyNameParam').val();
	partyNameParam = decodeURI(decodeURI(partyNameParam));
	if(partyNameParam != ''){
		$('#partyName').val(partyNameParam);
	}
});

</script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<input type="hidden" id="flag" value="${flag }">
<input type="hidden" id="partyNameParam" value="${partyNameParam }">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="25" align="center" valign="bottom" class="td06"><table width="98%" border="0" cellspacing="3" cellpadding="0">
      <tr>
        <td width="15"><img src="/djzx/images/index_32.gif" width="9" height="9"></td>
        <td valign="bottom" class="title">新增党建动态</td>
      </tr>
    </table></td>
  </tr>
</table>
<br>
<form action="/djzx/CommunityPartyActivityAction!savePartyActivity.action" method="post" id="form1" enctype="multipart/form-data">
<table align="center" width="95%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="90" height="24" class="td_form01">党组织名称</td>
        <td nowrap class=td_form02>
        	<select name="partyName" id="partyName">
        	  <s:iterator value="communityGeneralPartyList" var="c" status="statu">
        	  	<option value="${c.name }">${c.name }</option>
        	  </s:iterator>
        	  <s:iterator value="communityPartyList" var="c" status="statu">
        	  	<option value="${c.name }">${c.name }</option>
        	  </s:iterator>
      		</select>
        </td>
        <td width="90" class="td_form01">活动名称</td>
        <td nowrap class=td_form02>
        	<input type="text" name="activityName" id="activityName" size="30" />
        </td>
      </tr>
      <tr>
        <td height="24" class="td_form01">活动类型</td>
        <td nowrap class=td_form02>
        	<select name="activityType" id="activityType">
              <option value="公益类">公益类</option>
			  <option value="服务类">服务类</option>
			  <option value="其他">其他</option>
      		</select>
        </td>
        <td class="td_form01">活动日期</td>
        <td nowrap class=td_form02>
        	<input type="text" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})" name="activityDate" id="activityDate" readonly="readonly" />
			<img alt="" src="/djzx/images/datePicker.png">
		</td>
      </tr>
	  <tr>
        <td height="24" class="td_form01">活动地点</td>
        <td nowrap class=td_form02>
        	<input type="text" name="address" id="address" size="30" />
        </td>
        <td class="td_form01">参加人数</td>
        <td nowrap class=td_form02>
        	<input type="text" name="attendNum" id="attendNum" size="30" />
        </td>
      </tr>
	  <tr>
		<td class="td_form01">活动内容</td>
        <td nowrap class=td_form02 colspan="3">
        	<textarea style="width:300px;height:200px" name="content" id="content"></textarea>
		</td>
      </tr>
      <tr>
        <td class="td_form01">活动情况</td>
        <td nowrap class=td_form02 colspan="3">
        	<textarea style="width:300px;height:200px" name="situation" id="situation"></textarea>
		</td>
      </tr>
      <tr>
        <td class="td_form01">上传图片</td>
        <td nowrap class=td_form02 colspan="3">
        	<input type="file" style="border:none" id="image" name="image" accept="image/*" multiple="multiple"/>
		</td>
      </tr>
</table>
</form> 
<br>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center"><input name="Submit2" type="submit" class="buttonface" value="  保存  " onClick="savePartyActivity()">
    <input name="Submit" type="submit" class="buttonface" value="  返回  "  onClick="goback()"></td>
  </tr>
</table>
<br>
</body>
</html>